<?php
/*
 * This is to send email using sendgrid.
 * By: Savan Koradia
 * Email: koradia.savan@gmail.com
 * Blog: http://fedoracores.blogspot.in
 */

Class System_Mail {

    public function __construct() {
        
    }

    /**
     * 
     * @param type $data
     */
    public function sendMail($data) {
        $fromEmail = 'sjk.frills2008@gmail.com';
        $fromName = 'Savan Koradia @VijaySales';
        $toEmail = $data['toEmail'];
        $toName = ($data['toName'] == null) ? $toEmail : $data['toName'];
        $subject = $data['subject'];
        $body = $data['body'];
        $header = new System_Smtpheader();
        $header->setUniqueArgs($data['uniqueArgs']);
        $mail = new Zend_Mail();
        $mail->setFrom($fromEmail, $fromName);
        $mail->addTo($toEmail, $toName);
        $mail->setSubject($subject);
        $mail->setBodyHtml($body);
//            $mailServerPath = $values['server_path'];
//            $username = $values['api_key'];
//            $password = $values['api_secret'];
        $mailServerPath = "smtp.sendgrid.com";
        $username = "sjk.frills2008";
        $password = "password$";
        $config = array('ssl' => 'tls',
            'port' => '587',
            'auth' => 'login',
            'username' => $username,
            'password' => $password);
        $transport = new Zend_Mail_Transport_Smtp($mailServerPath, $config);
        $header->addTo($mail);
        $mail->send($transport);
    }

}
